Move mark check to gtk_text_view_scroll_to_mark()
authorKristian Rietveld <kris@gtk.org>
Fri, 4 Sep 2009 14:38:04 +0000 (16:38 +0200)
committerKristian Rietveld <kris@gtk.org>
Fri, 4 Sep 2009 15:08:29 +0000 (17:08 +0200)
Also use a different means to check that the given mark is in the text
view's buffer.  This will also play nice with anonymous and NULL marks.
Suggested by Paolo Borelli.

gtk/gtktextview.c

index 72d7fe3a1c7b6b08da64f83a49bdacd60b9472aa..ad9cba06f4ac5cda5ecd55674b4285a0a64761eb 100644 (file)
@@ -1900,7 +1900,6 @@ gtk_text_view_queue_scroll (GtkTextView   *text_view,
                             gdouble        xalign,
                             gdouble        yalign)
 {
-  const char *mark_name;
   GtkTextIter iter;
   GtkTextPendingScroll *scroll;
 
@@ -1913,12 +1912,6 @@ gtk_text_view_queue_scroll (GtkTextView   *text_view,
   scroll->xalign = xalign;
   scroll->yalign = yalign;
   
-  /* We need to verify that the buffer contains the mark, otherwise this
-   * can lead to data structure corruption later on.
-   */
-  mark_name = gtk_text_mark_get_name (mark);
-  g_return_if_fail (gtk_text_buffer_get_mark (get_buffer (text_view), mark_name));
-
   gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, mark);
 
   scroll->mark = gtk_text_buffer_create_mark (get_buffer (text_view),
@@ -2167,6 +2160,11 @@ gtk_text_view_scroll_to_mark (GtkTextView *text_view,
   g_return_if_fail (xalign >= 0.0 && xalign <= 1.0);
   g_return_if_fail (yalign >= 0.0 && yalign <= 1.0);
 
+  /* We need to verify that the buffer contains the mark, otherwise this
+   * can lead to data structure corruption later on.
+   */
+  g_return_if_fail (get_buffer (text_view) == gtk_text_mark_get_buffer (mark));
+
   gtk_text_view_queue_scroll (text_view, mark,
                               within_margin,
                               use_align,